package main
import "fmt"

func main() {
    var n [10]int
    var i, j int
    
    for i = 0; i < 10; i ++ {
        n [i] = i + 100
    }

    for j = 0; j < 10; j++ {
        fmt.Printf("Element[%d] = %d\n", j, n[j])
    }

    // 二维数组
    values := [][]int {}
    row1 := []int {1, 2, 3}
    row2 := []int {4, 5, 6}
    values = append(values, row1)
    values = append(values, row2)
    fmt.Println("Row 1")
    fmt.Println(values[0])
    fmt.Println("Row 2")
    fmt.Println(values[1])
    fmt.Println("第一个元素为：")
    fmt.Println(values[0][0])
    /*
     * 初始化二维数组
     * a := [3][4]int {
     *     {0, 1, 2, 3},
     *     {4, 5, 6, 7},
     *     {8, 9, 10, 11}, // 必须要有逗号
     *}
     */
    sites := [2][2]string {}
    sites[0][0] = "Google"
    sites[0][1] = "Runoob"
    sites[1][0] = "Taobao"
    sites[1][1] = "Weibo"
    fmt.Println(sites)
    var a = [5][2]int {{0, 0}, {1, 2}, {2, 4}, {3, 6}, {4, 8}}
    for i = 0; i < 5; i++ {
        for j = 0; j < 2; j++ {
            fmt.Printf("a[%d][%d] = %d\n", i, j, a[i][j])
        }
    }
    // 创建空的二维数组
    animals := [][]string{}
    // 创建三一维数组，各数组长度不同
    row11 := []string{"fish", "shark", "eel"}
    row22 := []string{"bird"}
    row33 := []string{"lizard", "salamander"}
    // 使用 append() 函数将一维数组添加到二维数组中
    animals = append(animals, row11)
    animals = append(animals, row22)
    animals = append(animals, row33)

    // 循环输出
    for i := range animals {
        fmt.Printf("Row: %v\n", i)
        fmt.Println(animals[i])
    }
}
